'use strict';
var React = require('react'),
	ReactDOM = require('react-dom'),
	ChoiceQuestion = require('./choiceQuestion'),
	CheckQuestion = require('./checkQuestion'),
	CompletionQuestion = require('./completionQuestion').CompletionQuestion;

var Question = React.createClass({
	getCurValue:function(){
		console.log(this.refs);
		return this.refs.question.getAnswer();
	},
	render : function(){
		console.log('question render ......');
		var self = this;
		var res = [];
		switch(this.props.question.type){
			case '01':
			case '02':
			res.push(
				<ChoiceQuestion 
				 ref = 'question'
				 question = {this.props.question} 
				 key={'choice'} 
				 curValue = {this.props.curValue}
				 type= {this.props.question.type == '01' ? 'radio' : 'checkbox'} />
			);
			break;
			case '03':
			res.push(
				<CheckQuestion
				ref = 'question'
				question = {this.props.question}
				curValue = {this.props.curValue} 
				key = 'check'/>
			);
			break;
			case '04':

			res.push(
				<CompletionQuestion 
					ref = 'question'
					question = {this.props.question}
					curValue = {this.props.curValue}
					key = 'completion'/>
		    );
			break;
		}
		return (
			<div>
				{res}
			</div>
		);
	}
});

module.exports = Question;